package net.zjitc.controller;

import net.zjitc.aop.Pager;
import net.zjitc.context.LocalThreadHolder;
import net.zjitc.pojo.api.Result;
import net.zjitc.pojo.dto.query.extend.BookRssHistoryQueryDto;
import net.zjitc.pojo.entity.BookRssHistory;
import net.zjitc.pojo.vo.BookRssHistoryVO;
import net.zjitc.service.BookRssHistoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

//书籍订阅
@RestController
@RequestMapping(value = "/bookRssHistory")
public class BookRssHistoryController {

    @Resource
    private BookRssHistoryService bookRssHistoryService;

    //书籍订阅新增
    @PostMapping(value = "/save")
    public Result<Void> save(@RequestBody BookRssHistory bookRssHistory) {
        return bookRssHistoryService.save(bookRssHistory);
    }

    //删除
    @PostMapping(value = "/batchDelete")
    public Result<Void> batchDelete(@RequestBody List<Integer> ids) {
        return bookRssHistoryService.batchDelete(ids);
    }

    //修改
    @PutMapping(value = "/update")
    public Result<Void> update(@RequestBody BookRssHistory bookRssHistory) {
        return bookRssHistoryService.update(bookRssHistory);
    }

    //书籍订阅用户查询
    @Pager
    @PostMapping(value = "/queryUser")
    public Result<List<BookRssHistoryVO>> queryUser(@RequestBody BookRssHistoryQueryDto bookRssHistoryQueryDto) {
        bookRssHistoryQueryDto.setUserId(LocalThreadHolder.getUserId());
        return bookRssHistoryService.query(bookRssHistoryQueryDto);
    }

    //书籍订阅查询
    @Pager
    @PostMapping(value = "/query")
    public Result<List<BookRssHistoryVO>> query(@RequestBody BookRssHistoryQueryDto bookRssHistoryQueryDto) {
        return bookRssHistoryService.query(bookRssHistoryQueryDto);
    }

}
